package leetcode.sorted;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;

public class Bubble  {
    @Test
    public void sort()  {
        // 对 arr 进行拷贝，不改变参数内容
        int[] arr = {};

        for (int i = 1; i < arr.length; i++) {
            boolean flag = true;
            for (int j = 0; j < arr.length-i; j++) {
                if(arr[j]>arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                    flag = false;
//                    System.out.println(false);
                }
            }
            if (flag) {
                break;
            }

        }
        String a = Arrays.toString(arr);
        System.out.println(a);
    }
}